<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input type="text" placeholder="数量" id="i1">
    <input type="button" value="加图" onclick="f(1)">
    <input type="button" value="加片" onclick="f(2)">
    <script>
        function f(x) {
            for (let j = 0; j < i1.value; j++) {
                //根据点击不同的按钮传递的数值得到不同的图片
                let imgName = x == 1 ? "a.jpg" : "b.jpg";
                let i = document.createElement("img"); //创建图片标签对象
                i.src = imgName; //修改src属性的值
                document.body.appendChild(i); //添加到页面中
            }
         }
    </script>
</body>
</html>